var express = require('express');
var router = express.Router();
var multiparty = require('multiparty')
var xlsx = require('node-xlsx')
var fs = require('fs')
var jwt = require('jsonwebtoken')
/* GET home page. */
router.get('/', function (req, res, next) {
  res.render('index', { title: 'Express' });
});


//上传图片
// router.post('/addupload', (req, res) => {
//   let form = new multiparty.Form()
//   form.uploadDir = 'upload'
//   form.parse(req, (err, formData, imgData) => {
//     res.send({
//       code: 200,
//       path: 'http://localhost:3000/' + imgData.file[0].path
//     })
//   })
// })

// router.get('/top', async (req, res) => {
//   let cateList = await shopModel.find().lean()
//   let cateObj = {}

//   cateList.forEach(item => {
//     cateObj[item._id] = item
//   })
//   let list = []
//   cateList.forEach(item => {
//     if (!item['pid']) {
//       list.push(item)
//     } else {
//       if (cateObj[item.pid] && !cateObj[item.pid]['children']) {
//         cateObj[item.pid]['children'] = []
//       }
//       if (cateObj[item.pid]) {
//         cateObj[item.pid]['children'].push(item)
//       }
//     }
//   })
//   res.send({
//     list
//   })
// })
module.exports = router;
